package com.tlb.springboot.starter.rocketmq.config;

import com.aliyun.openservices.ons.api.impl.authority.SessionCredentials;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author yuaneg 2018/8/30
 */
@Data
@ConfigurationProperties(prefix = "spring.rocketmq")
public class RocketMqProperties {

    /**
     * name server
     */
    private String nameServer;


    /**
     * 是否开启client端的日志
     */
    private boolean enableClientLog;

    /**
     * 生产者相关配置
     */
    private Producer producer = new Producer();

    /**
     * 阿里云auth 认证
     */
    private SessionCredentials sessionCredentials;

    @Data
    public class Producer {


        /**
         * rocketMqproducer默认配置时需要配置的group
         */
        private String defaultGroup = "this-default-producer-group";

        /**
         * millis of send message timeout
         */
        private int sendMsgTimeout = 3000;

        /**
         * Compress message body threshold, namely, message body larger than 4k will be compressed on default.
         */
        private int compressMsgBodyOverHowMuch = 1024 * 4;

        /**
         * <p> Maximum number of retry to perform internally before claiming sending failure in synchronous mode. </p>
         * This may potentially cause message duplication which is up to application developers to resolve.
         */
        private int retryTimesWhenSendFailed = 2;

        /**
         * <p> Maximum number of retry to perform internally before claiming sending failure in asynchronous mode. </p>
         * This may potentially cause message duplication which is up to application developers to resolve.
         */
        private int retryTimesWhenSendAsyncFailed = 2;

        /**
         * Indicate whether to retry another broker on sending failure internally.
         */
        private boolean retryAnotherBrokerWhenNotStoreOk = true;

        /**
         * Maximum allowed message size in bytes.  // 4M
         */
        private int maxMessageSize = 1024 * 1024 * 4;
    }

}
